package sysUtil

import org.json.JSONObject

enum ResultJson {

    /**
     * code ：状态码(200:正常，其他code可自定义)
     * message：状态信息
     * data:返回数据
     * @return  com.google.gson.JsonObject
     */

//    static final String CODE = "code"
//    static final String MESSAGE = "message"
//    static final String DATA = "data"
    //msg ,count 用于分页默认对接受参数
//,OPTS("opts") 操作权限
    CODE("code"),MESSAGE("message"),
    DATA("data"),MSG("msg"),
    COUNT("count"),COLS("cols"),
    STATUS("status"),TABLE("table"),
    PANEL("panel"),URL("url"),
    PANEL_ID("panelId"),
    FORM_ITEM("formItem"),
    WHERE("where")

    public String name;

    public  ResultJson(name){
        this.name = name
    }

    public static JSONObject resultJson(){
        def result = JSONObject.newInstance()
        result.put(CODE.name, ResultCode.OPT_SUCCESS.code )
        result.put(MESSAGE.name,ResultCode.OPT_SUCCESS.message)
        result.put(MSG.name,ResultCode.OPT_SUCCESS.message)
        result.put(DATA.name,null)
        result.put(COUNT.name,0)
        return  result
    }

    public static Map resultMap(){
        def result = new HashMap()
        result.put(CODE.name, ResultCode.OPT_SUCCESS.code )
        result.put(MESSAGE.name,ResultCode.OPT_SUCCESS.message)
        result.put(DATA.name,null)
        result.put(MSG.name,null)
        result.put(COUNT.name,0)
        return  result
    }

}
